package com.freesun.monitor.db;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by yangfei on 13-12-6.
 */
public class MultSelectMariaDb implements Runnable {

    private Logger log = LoggerFactory.getLogger(this.getClass());
    private String tag = "MultSelectMariaDb";

    private OperateMariaDb operateMariaDb;
    private String sql;


    public MultSelectMariaDb(String sql, OperateMariaDb operateMariaDb) {
        this.sql = sql;
        this.operateMariaDb = operateMariaDb;
    }

    @Override
    public void run() {
        ResultSet rs = this.operateMariaDb.SelectData(this.sql);
        try {
            while (rs.next()) {
                log.debug(String.valueOf(rs.getInt(1)) + String.valueOf(rs.getString(2)) + String.valueOf(rs.getString(3)) + String.valueOf(rs.getString(4)) + String.valueOf(rs.getTimestamp(5)) + String.valueOf(rs.getTimestamp(6)));
            }

            rs.close();
        } catch (SQLException e) {
            log.error("批量查询失败!");
            e.printStackTrace();
        }

    }
}
